package edu.nf.ch02.controller;

import edu.nf.ch02.vo.ResultVO;
import org.springframework.http.HttpStatus;

/**
 * @author wangl
 * @date 2025/5/13
 */
public class BaseController {

    /**
     * 响应成功（带数据）
     * @param data
     * @return
     * @param <T>
     */
    protected  <T> ResultVO<T> success(T data) {
        ResultVO<T> vo = new ResultVO<>();
        vo.setCode(HttpStatus.OK.value());
        vo.setData(data);
        return vo;
    }

    /**
     * 仅响应成功
     * @return
     * @param <T>
     */
    protected <T> ResultVO<T> success() {
        ResultVO<T> vo = new ResultVO<>();
        vo.setCode(HttpStatus.OK.value());
        return vo;
    }
}